import { defineStore} from "pinia";
import { reactive, ref, shallowRef } from "vue";
import { ApiClass, ApiStudent } from "../../api";


export const useStudentStore = defineStore("student", () => {
const model = reactive<API.Student.List>({
  stu_name: "",
  stu_cls_id: 0,
  stu_qualification: 0,
  begin: 0,
  pageSize: 3,
});
const list=ref<PageResult<UI.List>>()

const classRoomList=ref<UI.Class[]>()
const classList=ref<UI.Class[]>()
ApiStudent.classList().then((data)=>{
    classRoomList.value=data
})

  const queryHandler=async()=>{
   list.value = await ApiStudent.list(model);
  }
ApiClass.get().then((data)=>{classList.value=data})
  ApiStudent.list(model).then((data)=>{list.value=data})
  return {
    model,
    list,
    classRoomList,
    queryHandler,
    classList
  };
});
